<template>
	<view>
		<!-- 顶部导航栏 -->
		<cu-custom bgColor="bg-gradual-green" :isBack="true">
			<block slot="content">今日课程</block>
		</cu-custom>
		
		<message ref="message"></message>
		
		<view v-if="todayList.length===0" class="margin padding flex justify-center align-center text-black text-xl">
			<view class="cuIcon cuIcon-emoji margin-right-sm"></view>
			今日暂无课程
		</view>
		<course-list-item v-else :course="item" v-for="(item, index) in todayList" :key="index"></course-list-item>
		
	</view>
</template>

<script>
	import CourseListItem from "@/components/course-list-item/course-list-item.vue"
	import { getTodayCourse } from "@/api/course.js"
	
	export default {
		components:{
			CourseListItem
		},
		data() {
			return {
				todayList: []
			}
		},
		created() {
			if(!uni.getStorageSync('token')){
				uni.navigateTo({
					url: "/pages/login/login"
				})
			}
			this.getTodayCourse()
		},
		methods: {
			// 获取今日课程
			getTodayCourse(){
				getTodayCourse().then(res => {
					this.todayList = res.data
				})
			}
		}
	}
</script>

<style>

</style>
